BASS_StreamCreateFile

Creates a sample stream from an MP3 or WAV file.

HSTREAM WINAPI BASS_StreamCreateFile(
    BOOL mem,
    void *file,
    DWORD offset,
    DWORD length,
    DWORD flags
);

Parameters
memTRUE = stream the file from memory.
fileFilename (mem = FALSE) or a memory location (mem = TRUE).
offsetFile offset to begin streaming from (only used if mem = FALSE).
lengthData length... 0 = use all data up to the end of the file (if mem = FALSE).
flagsAny combination of these flags.
BASS_SAMPLE_3DUse 3D functionality. This is ignored if BASS_DEVICE_3D wasn't specified when calling BASS_Init.
BASS_MP3_HALFRATEHalf the MP3's sample rate, reducing the CPU usage. This flag is automatically applied if the halved rate is equal to or above the output rate specified when calling BASS_Init, as there is no point mixing the MP3 at a higher rate than it is actually being heard at.

Return value
If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes
BASS_ERROR_INITBASS_Init has not been successfully called.
BASS_ERROR_FILEOPENThe file could not be opened.
BASS_ERROR_FORMATThe file's format is not recognised/supported.
BASS_ERROR_MEMThere is insufficent memory.
BASS_ERROR_NO3DCouldn't initialize 3D support for the stream.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks
MPEG 1.0 and 2.0 layer 3 files are supported, layers 1 and 2 are not. But they have worse quality and compression ratios, so it's no big loss!

WAV files can be in standard Windows PCM format or they can be compressed with any CODEC, but the CODEC is required to be installed on the user's computer for the WAV to be decoded. So, you should either distribute the CODEC with your software, or use a CODEC that comes with Windows (eg. Microsoft ADPCM).

Use BASS_ChannelGetAttributes and BASS_ChannelGetFlags to retrieve information on the format (sample rate, resolution, channels) of the stream.

Example
To stream an MP3 file, using reduced quality.

BASS_StreamFileCreate(FALSE,"afile.mp3",0,0,BASS_MP3_HALFRATE);

See also
BASS_ChannelGetAttributes, BASS_ChannelGetFlags, BASS_ChannelSet3DAttributes, BASS_ChannelSet3DPosition, BASS_ChannelSetAttributes, BASS_ChannelSetEAXMix, BASS_StreamCreate, BASS_StreamFree, BASS_StreamPlay